package com.yz.vi.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yz.vi.admin.mapper.AdminMapper;
import com.yz.vi.admin.service.AdminService;
import com.yz.vi.commons.po.AdminPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @description:
 * @author: yutingting
 * @create: 2021-01-24 15:10
 **/
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    @Override
    public String getPwdByAccount(String account) {
        return adminMapper.selectOne(
                new QueryWrapper<AdminPO>().lambda().eq(AdminPO::getAccount, account)
                        .select(AdminPO::getPassword)
        ).getPassword();
    }

    @Override
    public List<String> selectBySex(Integer sex) {
        return adminMapper.selectList(new QueryWrapper<AdminPO>().lambda()
                .eq(Objects.nonNull(sex), AdminPO::getGender, sex).select(AdminPO::getAdminName))
                .stream()
                .map(AdminPO::getAdminName).collect(Collectors.toList());
    }


}
